<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/jquery.js"></script>
    <style>
        html,body{
            width: 100%;
            height: 100%;
        }
        *{margin: 0;padding: 0;}

        .floor{
            position: fixed;
            top: 100px;
            left: 10px;
            text-align: center;
            background-color: #fff;
            display: none;
        }
        .floor li{
            list-style: none;
            width: 60px;
            height: 30px;
            border: 1px solid #000;
            line-height: 30px;
        }
        .floor .selected{
            background-color: lightgoldenrodyellow;
        }
        .top .nav{
            height: 300px;
            background-color: khaki;
        }
        .top .banner{
            height: 500px;
            background-color: lawngreen;
        }
        .content .box{
            height: 500px;
            border: 1px solid #000;
            text-align: center;
            font-size: 50px;
            box-sizing: border-box;
        }
        .foot{
            height: 800px;
            background-color: lightblue;
        }
    </style>
</head>
<body>
    <div class="floor">
        <li class="selected">1楼</li>
        <li>2楼</li>
        <li>3楼</li>
        <li>4楼</li>
        <li>5楼</li>
        <li>6楼</li>
        <li>7楼</li>
    </div>
    <div class="container">
        <div class="top">
            <div class="nav"></div>
            <div class="banner"></div>
        </div>
        <div class="content">
            <div class="box">1</div>
            <div class="box">2</div>
            <div class="box">3</div>
            <div class="box">4</div>
            <div class="box">5</div>
            <div class="box">6</div>
            <div class="box">7</div>
        </div>
        <div class="foot"></div>
    </div>
    <script>
        $(function(){ 
            var $list=Array.from($(".box")).map(item=>item.offsetTop+$(item).outerHeight())
            var $list2=Array.from($(".box")).map(item=>item.offsetTop)

            $(document).on("scroll",function(){
                var $height=$(window).scrollTop()
               

                let $index=$list.findIndex(item=>item>$height)
                if($height>$(".banner").offset().top){
                    $(".floor").show()
                }else{
                    $(".floor").hide()
                }

                $(".floor li").eq($index).addClass("selected").siblings().removeClass("selected")
            })
            $(".floor li").on("click",function(){
                    $tempIndex=$(this).index()
                    $("body,html").animate({
                        scrollTop:$list2[$tempIndex]
                    })
                })
        })
    </script>
</body>
</html>